<nav class="mui-bar mui-bar-tab" id="tab">
    <!-- mui-active -->
    <a class="mui-tab-item" href="{:url('/')}">
        <span class="mui-icon mui-icon-home"></span>
        <span class="mui-tab-label">首页</span>
    </a>
    <a class="mui-tab-item" href="{:url('/home/subject/subject/index')}">
        <span class="mui-icon mui-icon-search"></span>
        <span class="mui-tab-label">搜索</span>
    </a>
    <a class="mui-tab-item" href="{:url('home/business/index')}">
        <span class="mui-icon mui-icon-contact"></span>
        <span class="mui-tab-label">个人中心</span>
    </a>
</nav>

<script>
    mui('#tab').on('tap','a',function(){
       location.href = this.href
    })

    var pathArr = location.pathname.split('/')

    var path = pathArr.filter((val) => {
        return val && val.trim()
    })

    path = path.slice(0,2).join('/')

    if(path == 'home/index' || path == '')
    {
        $('#tab a').eq(0).addClass('mui-active')
    }else if(path == 'home/subject'){
        $('#tab a').eq(1).addClass('mui-active')
    }else if(path == 'home/business')
    {
        $('#tab a').eq(2).addClass('mui-active')
    }
</script>